package com.cloudm.technician.extensions

import android.content.Context
import android.util.DisplayMetrics
import android.view.WindowManager

/**
 * 作者: wesley
 * 时间: 2017/12/22
 * 描述: 屏幕的扩展函数
 */


/**
 * 获取屏幕宽度
 */
fun Context.getScreenWidth(): Int {
    val windowManager = getSystemService(Context.WINDOW_SERVICE) as? WindowManager ?: return 0
    val display = DisplayMetrics()
    windowManager.defaultDisplay?.getMetrics(display)
    return display.widthPixels
}


/**
 * 获取屏幕高度
 */
fun Context.getScreenHeight(): Int{
    val windowManager = getSystemService(Context.WINDOW_SERVICE) as? WindowManager ?: return 0
    val display = DisplayMetrics()
    windowManager.defaultDisplay?.getMetrics(display)
    return display.heightPixels
}